using Godot;
using Godot.Collections;

public class Vector2I
{
    public int X;
    public int Y;
    public static Vector2I Up = new Vector2I(0, 1);
    public static Vector2I Down = new Vector2I(0, -1);
    public static Vector2I Left = new Vector2I(-1, 0);
    public static Vector2I Right = new Vector2I(1, 0);
    public Vector2I(int X, int Y)
    {
        this.X = X;
        this.Y = Y;
    }
    public Vector2I(float X, float Y)
    {
        this.X = (int)X;
        this.Y = (int)Y;
    }
    public Vector2I(Vector2 v2)
    {
        this.X = (int)v2.x;
        this.Y = (int)v2.y;
    }
    public Vector2I(Dictionary dict)
    {
        this.X = (int)dict["x"];
        this.Y = (int)dict["y"];
    }
    public void MoveUp() => Y += 1;
    public void MoveDown() => Y -= 1;
    public void MoveRight() => X += 1;
    public void MoveLeft() => X -= 1;

    public Vector2I ToUp() => new Vector2I(X, Y + 1);
    public Vector2I ToDown() => new Vector2I(X, Y - 1);
    public Vector2I ToLeft() => new Vector2I(X - 1, Y);
    public Vector2I ToRight() => new Vector2I(X + 1, Y);
    public static Vector2I operator +(Vector2I v1, Vector2I v)
    {
        return new Vector2I(v1.X + v.X, v1.Y + v.Y);
    }
    public static Vector2I operator -(Vector2I v1, Vector2I v)
    {
        return new Vector2I(v1.X - v.X, v1.Y - v.Y);
    }
    public static Vector2I operator *(Vector2I v1, Vector2I v)
    {
        return new Vector2I(v1.X * v.X, v1.Y * v.Y);
    }
    public static Vector2I operator *(Vector2I v1, int v)
    {
        return new Vector2I(v1.X * v, v1.Y * v);
    }
    public static Vector2I operator /(Vector2I v1, Vector2I v)
    {
        return new Vector2I(v1.X / v.X, v1.Y / v.Y);
    }
    public static Vector2I operator /(Vector2I v1, int v)
    {
        return new Vector2I(v1.X / v, v1.Y / v);
    }
    public Dictionary GetDictionary()
    {
        return new Dictionary(){
            { "x", this.X },
            { "y", this.Y },
        };
    }
}